Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate bindings from other patterns in HIR #33929

Merged
merged 3 commits into from
May 30, 2016
Merged

Conversation

petrochenkov
Copy link
Contributor

Now when name resolution is done on AST, we can avoid dumping everything that looks like an identifier into PatKind::Ident in HIR.
hir::PatKind::Ident is removed, fresh bindings are now called hir::PatKind::Binding, everything else goes to hir::PatKind::Path.

I intend to do something with PatKind::Path/PatKind::QPath as well using resolution results, but it requires some audit and maybe some deeper refactoring of relevant resolution/type checking code to do it properly.
I'm submitting this part of the patch earlier to notify interested parties that I'm working on this.

cc @jseyfried
r? @eddyb

/// referred to as simply `T::CONST`, in which case they will end up as
/// PatKind::Path, and the resolver will have to sort that out.
/// A path pattern written in qualified form, i.e. `<T as Trait>::CONST` or `<T>::CONST`.
/// Such patterns can only refer to associated constants at the moment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this comment change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it slipped from the later unpublished part of the patch.
The old comment basically says "yep, it's an associated constant" while it's only a syntactic form - qualified path, it can resolve to a constant, but it also can resolve to any other associated item - a method or an associated type (?), and passes working on HIR should be ready to deal with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/refer/legally refer/ would probably be better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it slipped from the later unpublished part of the patch.

Thought so. I'd take it out of this PR, it seems out of place.

@eddyb
Copy link
Member

eddyb commented May 28, 2016

@petrochenkov About path lowering, @nikomatsakis and I were discussion #33596 and we agreed that the proper solution involves having something like <<<T>::A>::B>::C as the desugaring for T::A::B::C (i.e. each path component which is an type gets its own hir::Ty node).

@petrochenkov
Copy link
Contributor Author

Updated.

@eddyb
Copy link
Member

eddyb commented May 28, 2016

@bors r+

@bors
Copy link
Contributor

bors commented May 28, 2016

📌 Commit ae999e9 has been approved by eddyb

@bors
Copy link
Contributor

bors commented May 29, 2016

⌛ Testing commit ae999e9 with merge d190a99...

@bors
Copy link
Contributor

bors commented May 29, 2016

💔 Test failed - auto-linux-64-opt-rustbuild

@arielb1
Copy link
Contributor

arielb1 commented May 29, 2016

@bors retry

@bors
Copy link
Contributor

bors commented May 30, 2016

⌛ Testing commit ae999e9 with merge bf9c60c...

bors added a commit that referenced this pull request May 30, 2016
Separate bindings from other patterns in HIR

Now when name resolution is done on AST, we can avoid dumping everything that looks like an identifier into `PatKind::Ident` in HIR.
`hir::PatKind::Ident` is removed, fresh bindings are now called `hir::PatKind::Binding`, everything else goes to `hir::PatKind::Path`.

I intend to do something with `PatKind::Path`/`PatKind::QPath` as well using resolution results, but it requires some audit and maybe some deeper refactoring of relevant resolution/type checking code to do it properly.
I'm submitting this part of the patch earlier to notify interested parties that I'm working on this.

cc @jseyfried
r? @eddyb
@bors bors merged commit ae999e9 into rust-lang:master May 30, 2016
bors added a commit that referenced this pull request Jun 9, 2016
Improvements to pattern resolution + some refactoring

Continuation of #33929
First commit is a careful rewrite of `resolve_pattern`, pattern path resolution and new binding creation logic is factored out in separate functions, some minor bugs are fixed. Also, `resolve_possibly_assoc_item` doesn't swallow modules now.
Later commits are refactorings, see the comment descriptions.

I intend to continue this work later with better support for `Def::Err` in patterns in post-resolve stages and cleanup of pattern resolution code in type checker.

Fixes #32086
Fixes #34047 ([breaking-change])
Fixes #34074

cc @jseyfried
r? @eddyb
@petrochenkov petrochenkov deleted the pathir branch September 21, 2016 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants